package licode.unisop.types.dp;

import org.springframework.util.Assert;

public class UserShare {

    public static final UserShare SHARED = new UserShare("shared");
    public static final UserShare NONE = new UserShare("none");

    private final String state;

    private UserShare(String state) {
        this.state = state;
    }

    public static UserShare build(String state) {
        if ("shared".equals(state)) {
            return UserShare.SHARED;
        } else if ("none".equals(state)) {
            return UserShare.NONE;
        } else {
            Assert.isTrue(false,
                    "非法的用户共享状态：" + state);
        }
        return null;
    }

    public boolean isShared() {
        return SHARED.state.equals(state);
    }

    public boolean isNone() {
        return NONE.state.equals(state);
    }

    public String getUserShare() {
        return state;
    }
}
